package com.igoal.dao;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.transaction.annotation.Transactional;

import com.igoal.entity.Comment;
import com.igoal.entity.ComponentEnum;

public interface CommentDAO extends GenericDao<Comment, Long> {
	/**
	 * Get comments before a date
	 * 
	 * @param componentId
	 * @param component
	 * @return
	 */
	List<Comment> getAllCommentsBefore(Long componentId, ComponentEnum component, Date updateBefore);

	/**
	 * Count all comments of a component
	 * 
	 * @param componentId
	 *            component identifier
	 * @param component
	 *            component type
	 * @return number of comments
	 */
	Map<Integer, Object> countCommentsOfComponent(Long componentId, ComponentEnum component);

	@Transactional(readOnly = false)
	void addComments(List<Comment> comments);

	@Transactional(readOnly = true)
	List<Comment> getLatestComments(Long componentId, ComponentEnum component);
	
	int countComments(Long componentId, ComponentEnum component);
}
